﻿using IntelligentAgriculture.Contracts.Dto.Output.ManageOutput;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;
using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.ManageCommand;
using IntelligentAgriculture.WebAPI.Application.Command.UserCommand;
using IntelligentAgriculture.WebAPI.Application.CommandHandler.UserCommandHandler;
using MediatR;
using System.Collections.Generic;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ManageHandler
{
    public class ManageCommandHander : IRequestHandler<ManageShowCommand, Results<PagesOutput<ManageShowOutput>>>
    {

        private readonly IManageService _manageService;
        private readonly ILogger<ManageCommandHander> _logger;
        public ManageCommandHander(IManageService manageService, ILogger<ManageCommandHander> logger)
        {
            _manageService = manageService;
            _logger = logger;
        }
        /// <summary>
        /// 提供耳标的显示、查询和分页功能
        /// </summary>
        /// <param name="request">包含显示、查询和分页所需的请求参数</param>
        /// <param name="cancellationToken">用于取消操作的令牌</param>
        /// <returns>返回执行耳标显示、查询和分页操作的结果</returns>
        public async Task<Results<PagesOutput<ManageShowOutput>>> Handle(ManageShowCommand request, CancellationToken cancellationToken)
        {
            var list = _manageService.GetShow(request.Eitag);
            var results = Results <PagesOutput<ManageShowOutput>>.DataResult(list);

            return results;

        }
    }
}
